<%@ Page Title="Right_Menu List" Language="C#" AutoEventWireup="true" CodeBehind="Right_MenuList.aspx.cs" Inherits="Youz.CreditRepay.Manage.Right_MenuList" %>

<script>
    //loadCSS("assets/plugins/gritter/css/jquery.gritter.css");

    var requireJS = [
        //"assets/plugins/gritter/js/jquery.gritter.min.js"
    ];

    loadJS(requireJS);
</script>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading" data-original-title>
                <h2><i class="fa fa-align-justify"></i><span style="font-size: 16px; padding-right: 15px;"><%: R(LanguageModule.Right_Menu, "Right_Menu", "Right_Menu") %></span></h2>
                <div class="panel-actions"></div>
            </div>
            <div class="panel-body">
                <div class="alert alert-danger" style="display: none;">
                    <button type="button" class="close" data-dismiss="alert">×</button><strong><i class="fa fa-warning"></i></strong><span class="content"></span>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <a href="#" class="btn btn-info" onclick="loadPage('Right/Right_MenuItem.aspx?st=<%: WebHelper.Get("st") %>')"><i class="fa fa-plus"></i>
                            <%: R(LanguageModule.M_Common, "Add") %></a>
                        <a href="#" class="btn btn-info" id="btnEdit"><i class="fa fa-edit "></i>
                            <%: R(LanguageModule.M_Common, "Edit") %></a>
                        <a href="#" class="btn btn-info" id="btnDelete"><i class="fa fa-trash-o "></i>
                            <%: R(LanguageModule.M_Common, "Delete") %></a>
                        <%--<a href="#" class="btn btn-info" onclick="addMember()"><i class="fa fa-user"></i>
                            <%: R(LanguageModule.Right_Menu, "ManageMember") %></a>--%>
                    </div>
                </div>
                <table id="table" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%"></table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var dt;

    $(function () {

        dt = $('#table').DataTable({
            "paging": false,
            "info": false,
            "ajax": {
                "url": 'Right/Handlers/Right_MenuHandler.ashx?type=list&st=' + <%: WebHelper.Get("st") %> + '',
                "type": "POST",
                "dataSrc": "data",
                "data": function (d) {
                }
            },
            "columns": [

                    { "data": 'MenuID', "title": "<%: R(LanguageModule.Right_Menu, "MenuID", "MenuID") %>" },
                    { "data": 'MenuNameEn', "title": "<%: R(LanguageModule.Right_Menu, "MenuName", "菜单名称") %>" },
                    { "data": 'MenuURL', "title": "<%: R(LanguageModule.Right_Menu, "MenuURL", "菜单路径") %>" },
                    { "data": 'MenuImage', "title": "<%: R(LanguageModule.Right_Menu, "MenuImage", "菜单图片") %>" },
                    { "data": 'Sort', "title": "<%: R(LanguageModule.Right_Menu, "Sort", "排序") %>" },
                    { "data": 'Remark', "title": "<%: R(LanguageModule.Right_Menu, "Remark", "备注") %>" },
                    { "data": 'IsEnabled', "title": "<%: R(LanguageModule.Right_Menu, "IsEnabled", "IsEnabled") %>", render: fYesNo },
                    { "data": 'ModifiedTime', "title": "<%: R(LanguageModule.Right_Menu, "ModifiedTime", "ModifiedTime") %>" },
            ]
        });

        //delete selected row
        $('#btnDelete').click(function () {
            if ($('#table tbody tr.selected').length > 0) {
                jconfirm("<%: R(LanguageModule.M_Common, "DeleteConfirm") %>", function () {
                    //console.log(dt.row('.selected').data());
                    $.post("Right/Handlers/Right_MenuHandler.ashx?type=delete&st=<%: WebHelper.Get("st") %>", { MenuID: dt.row('.selected').data().MenuID }, function (data) {
                        if (data) {
                            if (data.isSuccess) {
                                dt.ajax.reload();

                                $.gritter.add({
                                    title: '<%: R(LanguageModule.M_Common, "TipSuccess") %>',
                                    text: data.message,
                                    class_name: 'gritter-success'
                                });

                                $('#table tbody tr.selected').remove();
                            }
                            else {
                                $(".alert > .content").html(data.message);
                                $(".alert").show();
                            }
                        }
                    }, "json");
                });
            }
            else {
                $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
                $(".alert").show();
            }
        });

        //delete selected row
        $('#btnEdit').click(function () {
            if ($('#table tbody tr.selected').length > 0) {
                loadPage("Right/Right_MenuItem.aspx?MenuID=" + dt.row('.selected').data().MenuID + "&st=<%: WebHelper.Get("st") %>");
            }
            else {
                $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
                $(".alert").show();
            }
        });

    });
</script>
